#import "YQPLogicsInfoCell.h"

#import "YQPOrderLogicsViewController.h"

@interface YQPOrderLogicsViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (strong, nonatomic) YQPLogincsModel *model;

@end

@implementation YQPOrderLogicsViewController

static NSString *logicsCell = @"YQPLogicsInfoCell";

- (void)viewDidLoad {
    [super viewDidLoad];
    self.isNavShadow = YES;
    self.navigationItem.title = kYQLS(@"物流跟踪");

    self.listTableView.bounces = NO;
    
}

#pragma mark - 查看物流信息
- (void)queryLogicsInfo
{

    YQSHOWLOADINGINVIEW
    [YQPNetWorkingManager sendGetRequest:kGET_LOGICSTICS_GET_URL(self.orderId) parameters:nil success:^(YQPNetWorkingBaseModel * _Nonnull responseObject) {
        YQHIDELOADINGTIPS
        if (responseObject.code == 0) {
            self.model = [YQPLogincsModel mj_objectWithKeyValues:responseObject.data];
            [self.dataArr addObjectsFromArray:self.model.logisticsInfo];
            [self.listTableView reloadData];
        }else{
            YQUITIPSERROR(responseObject.msg)
        }
    } failure:^(NSUInteger statusCode, NSString * _Nonnull error) {
        YQUITIPSERROR(error)
        YQHIDELOADINGTIPS
    }];
}

-(void)setupView {
    [super setupView];
    
//    kYQREGISTERTABLEVIEWCELL[(@"YQPLogicsInfoCell")
    [self.listTableView registerClass:YQPLogicsInfoCell.class forCellReuseIdentifier:logicsCell];
    [self queryLogicsInfo];

}

#pragma mark - UITableViewDelegate, UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArr.count;
}
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    
    YQPLogicsInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:logicsCell];
    cell.model = self.dataArr[indexPath.row];
    
    return cell;
}

//-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
//    return 58;
//}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.001;
}
@end
